<%@page import="com.hamizhong.iflowers.utils.MyColumnIndicator"%>
<%@page import="com.hamizhong.iflowers.web.vo.GoodsVO"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@include file="../../common/common_admin.jsp" %>
<title>更新促销状态</title>
</head>
<%
	GoodsVO goodsVO = (GoodsVO)request.getAttribute("goodsVO");
%>
<body>
	<div class="displayPageHeader">当前位置：产商管理 >> 商品管理>> 商品更新</div>
	<div class="pageDiv">
		<div class="pageHeadDiv"><font>更新商品</font></div>
		<div class="infoDiv">
			<input type="text" style="display: none;" id="goodsId" name="goodsId" value="<%=goodsVO.getGoodsId() %>">
			<div class="pageDiv" style="margin-left: 10px;">
				<div style="background-color: #E3EFFB;height: 25px;line-height: 25px;padding-left: 10px;">基本信息</div>
				<div class="infoDiv">
					<table cellpadding="2px">
						<tr>
							<td style="width: 70px;">&nbsp;&nbsp;商品名称&nbsp;&nbsp;</td>
							<td>
								<div style="border-bottom: 1px dashed #999;padding: 5px;">
									<font><%=goodsVO.getGoodsName()%></font>
								</div>
							</td>
						</tr>
						<tr>
							<td style="width: 70px;">&nbsp;&nbsp;商品价格&nbsp;&nbsp;</td>
							<td>
								<div style="border-bottom: 1px dashed #999;padding: 5px;">
									<font><%=goodsVO.getGoodsPrice()%></font>
								</div>
							</td>
						</tr>
						<tr>
							<td style="width: 70px;">&nbsp;&nbsp;促销状态&nbsp;&nbsp;</td>
							<td>
								<div style="border-bottom: 1px dashed #999;padding: 5px;">
									<select id="isBargin" onchange="initBarginPriceDiv()" style="width: 150px;">
									<%
										if(goodsVO.getIsBargin() == MyColumnIndicator.G_BARGIN_ST_A0) {
									%>
										<option selected="selected" value="<%=MyColumnIndicator.G_BARGIN_ST_A0%>" ><%=MyColumnIndicator.G_BARGIN_ST_STR_A0 %></option>
										<option value="<%=MyColumnIndicator.G_BARGIN_ST_B1%>" ><%=MyColumnIndicator.G_BARGIN_ST_STR_B1 %></option>
									<%
										} else if (goodsVO.getIsBargin() == MyColumnIndicator.G_BARGIN_ST_B1) {
									%>
										<option value="<%=MyColumnIndicator.G_BARGIN_ST_A0%>" ><%=MyColumnIndicator.G_BARGIN_ST_STR_A0 %></option>
										<option selected="selected" value="<%=MyColumnIndicator.G_BARGIN_ST_B1%>" ><%=MyColumnIndicator.G_BARGIN_ST_STR_B1 %></option>
									<%	
										}
									%>
									</select>
								</div>
							</td>
						</tr>
						<tr>
							<td style="width: 70px;">&nbsp;&nbsp;促销价格&nbsp;&nbsp;</td>
							<td>
								<div id="barginPriceDiv" style="border-bottom: 1px dashed #999;padding: 5px;display: none;">
									<input type="text" name="barginPrice" id="barginPrice" style="width: 150px;" value="<%=goodsVO.getBarginPrice()%>">
								</div>
							</td>
						</tr>
					</table>
				</div>
			</div>
			<div class="pageDiv" style="margin-left: 10px;">
				<div style="background-color: #E3EFFB;height: 25px;line-height: 25px;padding-left: 10px;">操作栏</div>
				<div class="infoDiv">
					<input style="margin: 10px 0;" type="button" onclick="closeWindow();" value="取消修改">
					<input style="margin: 10px 0;" type="button" onclick="ajaxUpdateGoodsBarginState()" value="确认修改">
				</div>
			</div>
			
			<div class="margin_50"></div>
		</div>
	</div>
</body>

<script type="text/javascript">

//父窗口对象
var parentWindow = window.dialogArguments;

$(function() {
	initBarginPriceDiv();
});

function initBarginPriceDiv() {
	var isBargin = $('#isBargin').val();
	if(isBargin == <%=MyColumnIndicator.G_BARGIN_ST_A0 %>) {
		$('#barginPriceDiv').hide();
	}else if(isBargin == <%=MyColumnIndicator.G_BARGIN_ST_B1 %>) {
		$('#barginPriceDiv').show();
	}
}

function closeWindow() {
	window.close();
}

function ajaxUpdateGoodsBarginState() {
	var goodsId = $('#goodsId').val();
	var isBargin = $('#isBargin').val();
	var barginPrice = $('#barginPrice').val();
	$.ajax({
		url: '<%=request.getContextPath() %>/admin/ajaxUpdateGoodsBarginState.action',
		data: {
			"goodsId": goodsId,
			"isBargin": isBargin,
			"barginPrice": barginPrice
		},
		type: 'post',
		async: false,
		dataType: 'json',
		success: function(res) {
			var rs = res.result;
			if(rs == 0) {
				alert("修改成功！");
				parentWindow.initItemList(1);
				closeWindow();
			}else {
				var msg = res.msg;
				alert(msg);
				closeWindow();
			}
		}
	});
}

</script>

</html>